home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / allocwg.com / DISPSIZE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-10  |  2.9 KB  |  90 lines

  1. #include <dos.h>
  2.  
  3. DisplaySize ()
  4.  
  5. /*
  6.    +-----------------------------------------------------------+
  7.    |                                                           |
  8.    |  This procedure displays the current program size on the  |
  9.    |  first line of the screen when called.                    |
  10.    |                                                           |
  11.    +-----------------------------------------------------------+
  12. */
  13.  
  14. {  
  15.    int  row, column ;
  16.    long codesize, dataused, dataalloced, allocused, allocated ;
  17.    char string [83] ;
  18.  
  19.    ProgSize (&codesize, &dataused, &dataalloced, &allocused, &allocated) ;
  20.    getcursor    ( &row, &column ) ;
  21.    locatecursor ( 0   ,       0 ) ;
  22.  
  23.       /*  NOTE:  In the following message,
  24.  
  25.                      C:  refers to the program's code size (bytes).
  26.                     DU:  refers to how much space is actually being
  27.                            used in the program's default data segment. 
  28.                            (bytes).
  29.                     DA:  refers to how much space was actually allocated
  30.                            to the program's default data segment (bytes).
  31.                     AU:  refers to how much space has been allocated 
  32.                            via the memory allocation procedures (bytes).
  33.                     AA:  refers to how much space was actually allocated
  34.                            to accommodate the user memory allocations (bytes).
  35.                  Total:  refers to the total program size (bytes).
  36.       */
  37.     
  38.    printf ( 
  39.       "C: %6ld   DU: %6ld  DA: %6ld     AU: %6ld  AA: %6ld     Total: %6ld ",
  40.           codesize,  dataused, dataalloced, allocused, allocated, 
  41.           codesize + dataalloced + allocated ) ;        
  42.    locatecursor ( row ,  column ) ;
  43. }
  44.  
  45. static int getcursor ( row, column )
  46.  
  47.    int   *row    ;
  48.    int   *column ;
  49.  
  50. /*
  51.    +-----------------------------------------------------------+
  52.    |                                                           |
  53.    |  This procedure returns the current cursor position.      |
  54.    |                                                           |
  55.    +-----------------------------------------------------------+
  56. */
  57.  
  58. {
  59.    union REGS regs ;
  60.  
  61.    regs.h.ah = 0x03 ;
  62.    regs.h.bh =    0 ;
  63.    int86 ( 0x10, ®s, ®s ) ;
  64.    *row    = regs.h.dh ;
  65.    *column = regs.h.dl ;
  66. }
  67.  
  68. static int locatecursor ( row, column )
  69.  
  70.    int   row    ;
  71.    int   column ;
  72.  
  73. /*
  74.    +-----------------------------------------------------------+
  75.    |                                                           |
  76.    |  This procedure set the cursor position to row, column.   |
  77.    |                                                           |
  78.    +-----------------------------------------------------------+
  79. */
  80.  
  81. {
  82.    union REGS regs ;
  83.  
  84.    regs.h.ah = 0x02   ;
  85.    regs.h.bh =    0   ;
  86.    regs.h.dh = row    ;
  87.    regs.h.dl = column ;
  88.    int86 ( 0x10, ®s, ®s ) ;
  89. }
  90.